package com.ansion.user.listener;

import androidx.annotation.NonNull;

import com.ansion.basetool.preconditions.Preconditions;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


/**
 * created by zhaoyuntao
 * on 28/07/2020
 * description:
 */
public abstract class ContactsChangeListener extends BaseContactChangeListener {
    private Set<String> hidSet;

    public ContactsChangeListener() {

    }

    public void init(Collection<String> hidList) {
        Preconditions.checkNotNull(hidList);
        hidSet = new HashSet<>(hidList);
    }

    @Override
    public boolean match(@NonNull String hid) {
        Preconditions.checkNotEmpty(hidSet);
        return hidSet.contains(hid);
    }

    public List<String> getHidList() {
        Preconditions.checkNotEmpty(hidSet);
        return new ArrayList<>(hidSet);
    }
}
